﻿namespace NTLib.IOC.Containers
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;

    /// <summary>
    /// Define a container that could provide instance.
    /// </summary>
    public interface IContainer : IDisposable
    {
        #region Methods

        /// <summary>
        /// Determines whether this instance can handle the specified key.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns>
        ///   <c>true</c> if this instance can handle the specified key; otherwise, <c>false</c>.
        /// </returns>
        bool CanHandle(Type key);

        /// <summary>
        /// Gets the specified state.
        /// </summary>
        /// <typeparam name="TInstance">The type of the instance.</typeparam>
        /// <param name="state">The state.</param>
        /// <param name="token">The token.</param>
        /// <returns></returns>
        TInstance Get<TInstance>(object state = null, CancellationToken token = default(CancellationToken));

        #endregion
    }
}
